﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using TeamExplorer.Merge.Helper;

namespace TeamExplorer.Merge.Converters
{
    /// <summary> 
    /// Normalize the date and time to show relative time period
    /// </summary> 
    public class NormalizeDateTimeConverter : IValueConverter
    { 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        { 
            if (value == null) return null;
            DateTime inputDateTime = DateTime.Parse(value.ToString());
            DateTimeGroup group = Utility.GetNormalizedDateTimeGroup(inputDateTime);

            return Utility.GetDescriptionFromEnumValue(group); 
        } 
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
        { 
            return null; 
        } 
    } 
}
